﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<dbPoll_Application.ViewModels.ManageEntityHierarchyViewModel>" %>
<%@ Import Namespace="dbPoll_Application.Models"%>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Entity Hierarchy
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <script src="../../Scripts/_lib/jquery.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery.jstree.js" type="text/javascript"></script>
    <script src="../../Scripts/Poll-EntityHierarchy.js" type="text/javascript"></script>
    
    <div class="pageHeadingContainer"><h2 class="pageHeading">Entity Hierarchy</h2></div>
    <div id="contentContainer">
    <p><%= Html.ActionLink("Polls > ", "Index", "Poll", null, new { @class = "breadcrumb" })%><% if (Model.pollID < 0)
                                                                                                 { %>New Poll <% } %><%= Model.pollName %></p>
    <div id="pageMenuContainer">
        <% var pollRoles = ViewData["pollRoles"] as ICollection<dbPoll_Application.Models.Role>;
           var pollAdministrator = new dbPoll_Application.Models.Role("Poll Administrator");
           var pollCreator = new dbPoll_Application.Models.Role("Poll Creator");
           var pollMaster = new dbPoll_Application.Models.Role("Poll Master"); %>
        <ul id="pageMenu">
            <li><%= Html.ActionLink("Details", "Questions", new { pollID = Model.pollID }) %></li>
            <li id="runLink" <% if (Model.pollID < 0 || Model.poll.questions.Count == 0) { %> class="none" <% } %>><%= Html.ActionLink("Run", "SetSession", new { pollID = Model.pollID }) %></li>
            <li id="testLink" <% if (Model.pollID < 0 || Model.poll.questions.Count == 0) { %> class="none" <% } %>><%= Html.ActionLink("Test", "Test", new { pollID = Model.pollID }) %></li>
            <li><%= Html.ActionLink("Reports", "Reports", new { pollID = Model.pollID })%></li>
            <li>Manage Hierarchy</li>
        </ul>
    </div>        
        <div class="respondTitle"><div class="respondTitlePadding">Create the Hierarchy</div></div>
        <div id="hierarchyContainer">
            <div id="respondQuestionContainerPadding">
            <div id="respondInstructions"><p>The following entity hierarchy can be used to filter and aggregate the results collected during polling for reporting purposes.</p><p>Right-click on the hierarchy to add, edit, or delete entities.</p>
            </div>
            <div id="respondOptionsContainer">
                <%= Html.HiddenFor(model => model.pollID) %>
                <div id="tree">
                    <ul>
                    <% var tree = dbPoll_Application.Controllers.PollController.GetEntityTree(Model.root);
                    if (!String.IsNullOrEmpty(tree))
                    { %>    
                        <%= tree %>
                    <%} 
                    else
                    { %>
                        <li id="-1"><a href="#">New</a></li>
                    <%} %>
                    </ul>
                </div>
            </div>
        </div>
        </div>
    </div>

</asp:Content>
